#ifndef _DS1302_H_
#define _DS1302_H_
#include "sys.h"

sbit DS1302_CLK = P3^1;
sbit DS1302_DAT = P3^2;
sbit DS1302_RST = P3^3;

#define DS1302_DAT_IN()		P3MDOUT&=0xFB
#define DS1302_DAT_OUT()	P3MDOUT|=0x04

#define DS1302_SEC_ADDR				0x80
#define DS1302_MIN_ADDR				0x82
#define DS1302_HOUR_ADDR			0x84
#define DS1302_DAY_ADDR				0x86
#define DS1302_MONTH_ADDR			0x88
#define DS1302_WEEK_ADDR			0x8a
#define DS1302_YEAR_ADDR			0x8c
#define DS1302_CTRL_ADDR			0x8e


typedef struct{
	u8 sec;
	u8 min;
	u8 hour;
	u8 day;
	u8 month;
	u8 week;
	u8 year;
}DATE;

extern DATE cur_date;

void ds1302_init();
void ds1302_write_reg(u8 addr,u8 dat);
u8 ds1302_read_reg(u8 addr);
void ds1302_init_date();
void ds1302_read_date();
#endif